asm
  ld sp,$C7FF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $C010
dim seed as uinteger at $C012
dim ee0 as uinteger at $C014
dim ee1 as uinteger at $C016
dim ee2 as uinteger at $C018
dim ee3 as uinteger at $C01A
dim eex as uinteger at $C01C
dim eey as uinteger at $C01E

sub fieldcombatputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte):
  poke $D000+(txp1 bxor 31)*64+typ1,tch1
  end sub

seed=0

'for ee1=0 to 39 '- 12..51
'  for ee0=2 to 29
'    seed=smsrnd(seed)
'    fieldcombatputchar(ee0,ee1+12,32+(seed mod 64) )
'    smsdelay(500)
'    next:next

for ee1=0 to 39 '- 12..51
  for ee0=2 to 29
    seed=smsrnd(seed)
    fieldcombatputchar(ee0,ee1+12,1+(seed mod 3) )
    smsdelay(500)
    next:next

for ee1=0 to 15
  for ee0=0 to 15
    seed=smsrnd(seed)
    fieldcombatputchar(ee0+13,ee1+35,ee1*16+ee0 )
    smsdelay(500)
    next:next

eee=0:eex=8:eey=8
do

fieldcombatputchar(3,13,48+(int(eee/100) mod 10) )
fieldcombatputchar(4,13,48+(int(eee/10) mod 10) )
fieldcombatputchar(5,13,48+(eee mod 10) )

ee0=peek($E000) bxor $FF
fieldcombatputchar(3,15,48+(int(ee0/100) mod 10) )
fieldcombatputchar(4,15,48+(int(ee0/10) mod 10) )
fieldcombatputchar(5,15,48+(ee0 mod 10) )

eey=eey-((ee0 band 1)/1)+((ee0 band 2)/2)
eex=eex+((ee0 band 4)/4)-((ee0 band 8)/8)

ee0=peek($E100) bxor $FF
fieldcombatputchar(3,16,48+(int(ee0/100) mod 10) )
fieldcombatputchar(4,16,48+(int(ee0/10) mod 10) )
fieldcombatputchar(5,16,48+(ee0 mod 10) )

ee0=peek($E200) bxor $FF
fieldcombatputchar(3,17,48+(int(ee0/100) mod 10) )
fieldcombatputchar(4,17,48+(int(ee0/10) mod 10) )
fieldcombatputchar(5,17,48+(ee0 mod 10) )

ee0=peek($E300) bxor $FF
fieldcombatputchar(3,18,48+(int(ee0/100) mod 10) )
fieldcombatputchar(4,18,48+(int(ee0/10) mod 10) )
fieldcombatputchar(5,18,48+(ee0 mod 10) )



fieldcombatputchar(eex,eey+12,32+(eee mod 64) )

eee=eee+1:smsdelay(500)
loop

do:loop

'-------------------------------


do

for ee1=12 to 51
  for ee0=2 to 29
    seed=smsrnd(seed)
    fieldcombatputchar(ee0,ee1,seed)
    'poke $D000+(ee0*64)+ee1,seed
    smsdelay(2000)
    next:next

loop


do:loop


do

for ee2=$D000 to $D3FF 'videoram1
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(1000)
  next
for ee2=$D400 to $D7FF 'videoram2
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(1000)
  next


for ee2=$D800 to $D8FF 'spriteram
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(1000)
  next

loop

do:loop


'static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, fcombat_state )
'	AM_RANGE(0x0000, 0x7fff) AM_ROM
'	AM_RANGE(0xc000, 0xc7ff) AM_RAM
'	AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_SHARE("videoram")
'	AM_RANGE(0xd800, 0xd8ff) AM_RAM AM_SHARE("spriteram")
'	AM_RANGE(0xe000, 0xe000) AM_READ(fcombat_port01_r)
'	AM_RANGE(0xe100, 0xe100) AM_READ_PORT("DSW0")
'	AM_RANGE(0xe200, 0xe200) AM_READ_PORT("DSW1")
'	AM_RANGE(0xe300, 0xe300) AM_READ(e300_r)
'	AM_RANGE(0xe400, 0xe400) AM_READ(fcombat_protection_r) // protection?
'	AM_RANGE(0xe800, 0xe800) AM_WRITE(fcombat_videoreg_w)   // at least bit 0 for flip screen and joystick input multiplexor
'	AM_RANGE(0xe900, 0xe900) AM_WRITE(e900_w)
'	AM_RANGE(0xea00, 0xea00) AM_WRITE(ea00_w)
'	AM_RANGE(0xeb00, 0xeb00) AM_WRITE(eb00_w)
'	AM_RANGE(0xec00, 0xec00) AM_WRITE(ec00_w)
'	AM_RANGE(0xed00, 0xed00) AM_WRITE(ed00_w)
'	AM_RANGE(0xee00, 0xee00) AM_WRITE(ee00_w)   // related to protection ? - doesn't seem to have any effect
'	AM_RANGE(0xef00, 0xef00) AM_WRITE(soundlatch_byte_w)
'ADDRESS_MAP_END


